#include <stdio.h>
#include <assert.h>
#include "aimage.h"

void AIMAGE::view( void )
{
	FILE *f;
	int x,y;
	APIXEL *begin, *end, *cur;

	f = popen("xloadimage stdin", "w" );

	assert( f != NULL );

	fprintf(f, "P6\n");
	fprintf(f, "%d %d\n", m_width, m_height );
	fprintf(f, "255\n");

	begin = m_image[ 0 ];
	end = begin + ( m_width * m_height );

	for ( cur = begin; cur != end; ++cur )
	{
		fputc( cur->r >> 8, f );
		fputc( cur->g >> 8, f );
		fputc( cur->b >> 8, f );
	}
	pclose(f);
}

